<template>
	<div class="Word">
		<div>
			<div class="flow4">
				<input type="button" @click="exit()" value="关闭窗口" />
				<strong>当前用户：</strong>
				<span style="color: Red;">{{ paramValue }}</span>
			</div>
			<div style="height: 800px; width: auto" v-html="poHtmlCode" />
		</div>

	</div>
</template>

<script>
import request from '@/utils/request'
export default {
	data() {
		return {
			poHtmlCode: '',
			paramValue: ''
		}
	},
	created: function () {
		//使用pageofficectrl.WindowParams获取获取父页面中POBrowser.openWindow()方法的第三个参数的值,获取到的值为string类型
		this.paramValue = pageofficectrl.WindowParams;
		// 请求后端打开文件
		this.openFile().then(response => {
			this.poHtmlCode = response.pageoffice;
			this.paramValue = response.userName;
		});

	},
	methods: {
		exit() {
			pageofficectrl.CloseWindow();
		},
		Save() {
			pageofficectrl.SaveFilePage = "/SetDrByUserWord/save";
			//在这里写您保存前的代码
			pageofficectrl.WebSave();
			//在这里写您保存后的代码，比如判断保存结果pageofficectrl.CustomSaveResult
		},

		//全屏/还原
		IsFullScreen() {
			pageofficectrl.FullScreen = !pageofficectrl.FullScreen;
		},
		OnPageOfficeCtrlInit() {
			// PageOffice的初始化事件回调函数，您可以在这里添加自定义按钮
			pageofficectrl.AddCustomToolButton("保存", "Save", 1);
			pageofficectrl.AddCustomToolButton("全屏/还原", "IsFullScreen", 4);
		},
		openFile() {
			return request({
				url: '/SetDrByUserWord/Word?userName=' + this.paramValue,
				method: 'get',
			})
		}
	},
	mounted: function () {
		//将当前页面methods中定义的函数挂载到PageOffice控件，例如控件触发的事件、自定义按钮触发的函数。
		window.POPageMounted = this;//此行必须
	}
}
</script>
